import request from '@/utils/request'

const urls = {
  tree: 'admin/menu/tree',
  list: 'admin/menu/list'
}

export function list(params) {
  return request({
    url: urls.list,
    method: 'get',
    params
  })
}

export function getMenusTree(params) {
  return request({
    url: urls.tree,
    method: 'get',
    params
  })
}

export function getMenus(params) {
  return request({
    url: urls.list,
    method: 'get',
    params
  })
}

export function add(data) {
  return request({
    url: 'admin/menu/save',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'admin/menu/del',
    method: 'post',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'admin/menu/save',
    method: 'post',
    data
  })
}

export function buildMenus() {
  return getMenusTree({type: 1})
}

export default {add, edit, del, getMenusTree, getMenus, urls,list}
